home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3286 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: news.math.psu.edu!usenet
  2. From: wja@math.hust.china (Jeff Wu)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: using MALLOC() w/ 2-d arrays
  5. Date: 27 Jan 1996 11:22:55 -0500
  6. Organization: Chinese Basketball Club at Penn State (CBCPS)
  7. Sender: wja@stokes.math.psu.edu
  8. Message-ID: <xm2ohrphajk.fsf@stokes.math.psu.edu>
  9. References: <4e9nm2$nna@cville-srv.wam.umd.edu>
  10. NNTP-Posting-Host: stokes.math.psu.edu
  11. In-reply-to: jsquires@wam.umd.edu's message of 26 Jan 1996 05:09:22 GMT
  12.  
  13. Consider using pointer pointer.
  14.  
  15. --Jeff
  16.  
  17. In article <4e9nm2$nna@cville-srv.wam.umd.edu> jsquires@wam.umd.edu (jeffrey d squires) writes:
  18.  
  19.    From: jsquires@wam.umd.edu (jeffrey d squires)
  20.    Newsgroups: comp.lang.c
  21.    Date: 26 Jan 1996 05:09:22 GMT
  22.    Organization: University of Maryland College Park
  23.    Path: news.math.psu.edu!CTCnet!newsfeed.pitt.edu!gatech!newsfeed.internetmci.com!uwm.edu!lll-winken.llnl.gov!enews.sgi.com!decwrl!purdue!haven.umd.edu!cville-srv.wam.umd.edu!jsquires
  24.    Lines: 27
  25.    NNTP-Posting-Host: rac3.wam.umd.edu
  26.    X-Newsreader: TIN [version 1.2 PL0]
  27.  
  28.    I have a function that takes as one of its arguments:
  29.  
  30.    unsigned char image[MAX_Y][MAX_X}
  31.  
  32.  
  33.    I have a number of images which is determined at run time,
  34.    therefore I can't declare the size of image_array[][MAX_Y][MAX_X].
  35.  
  36.    In other words, I want to be able to allocate space for as many
  37.    of these images as I need at run time.  I've tried everything
  38.    (except the correct way).
  39.  
  40.    I think I need something of the form:
  41.  
  42.    unsigned char * image_array[MAX_Y][MAX_X];
  43.  
  44.    image_array = (unsigned char *) malloc(.....sizeof(unsigned char));
  45.  
  46.  
  47.    I know that if I declare:
  48.    unsigned char image_array[10][MAX_Y][MAX_X];
  49.  
  50.    I can successfully send this to the function, but what
  51.    if I don't know that I'll need ten?  Can anyone tell
  52.    me the proper solution?  Thank you.
  53.  
  54.  
  55.